local context = UI.CreateContext('LMVClntContext') 

local cmDg

function Send2Members(Data)
	Command.Message.Broadcast('raid', nil, "LootVoteInfo", Data, function (failed, message) VersionReqCheck(name, failed, message) end)
end

local strsplit = string.split

function PMessageHandler(From, Type, Channel, Identifier, Data)
			if Type == "raid" then --and Data ~= nil then
				if Identifier == "LootVoteReq" then
					print(From.." send "..Data)
  i = 1
--Inspect.Unit.Detail("player").calling

	local aa = strsplit(Data, ":")
Command.Tooltip(aa[1])
print(aa[1])
print(Inspect.Item.Detail(aa[1]))
print(Inspect.Item.Detail(aa[1]).name)


  local dialog = cmDg.dialog
  dialog.moveIcon:SetTexture({path = Inspect.Item.Detail(aa[1]).icon})

  dialog.message.element:SetText(tostring(Inspect.Item.Detail(aa[1]).name))
  dialog:SetVisible(true)
				end
			end

end



-- initializing function
----   still need to add events for right/left clicking
function init()
	
  local Ncolor = {border = "000000", body = "333333", header = "3B5998", title = "FFFFFF", message = 'FFFF0F'}

  cmDg = UI.CreateFrame('nkExtDialog', 'LMVClient', context, 
				{ rdesign = true, layer = 2, width = 500, height = 135,  color = Ncolor,
				title = 'Голосование за лут', message = '123456789 123456789 12345678933', 
				anchors = {{ from = "CENTER", object = UIParent, to = "CENTER"}}  })
  local buttonType, width = 'nkExtRiftButton', nil 
  local  height, fwidth = 15, 275 
  local dialog = cmDg.dialog

  dialog:SetVisible(false)
  btPattern={color=Ncolor,width = width, }
  mall={"CENTERRIGHT", "CENTERCENTER", "CENTERLEFT"}
  mlabel={'не нужен' , 'оффспек', 'майн спек', }
  dialog.But={}
  for num=1,3 do
    dialog.But[num] = UI.CreateFrame (buttonType, 'Button'..num, dialog.buttonFrame:getElement(), 
		      { anchors = {{ from = "CENTERCENTER", object = dialog.buttonFrame:getElement(), to = mall[num] }},
		      label = mlabel[num], 
		      pattern = btPattern, func = function () dialog:SetVisible(false); Send2Members(num..':'..mlabel[num]) end })
  end

  dialog.moveIcon = UI.CreateFrame ('nkExtTexture', 'nkon', dialog:getBody(true), 
				{ layer = 1, type = "Rift", --path = Inspect.Item.Detail("i0DAC80000A212008").icon,
			width = 50, height = 50, anchors = {{ from = "BOTTOMLEFT", object = dialog:getBody(true), to = "CENTERLEFT",x=10,y=0}} })


  Command.Message.Accept("raid", "LootVoteReq")
  table.insert(Event.Message.Receive, {PMessageHandler, "LootMasterVote", "Messenger Handler"})

end -- end init() 




-- get things rollling!
init()
